<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>物业管理系统</title>
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/AdminLTE.min.css">
</head>
<style>
</style>
<body style="padding-bottom: 90px; background-color: #FFF;">
<div class="modal-content">
		<div class="modal-body">
			<div class="input-group">
				<span class="input-group-addon">手机号：</span> <input type="text" class="form-control" id="tel">
			</div>
			<br />
			<div class="input-group">
				<span class="input-group-addon">车牌号：</span>
			      	<div class="input-group-btn">
				         <select class="form-control" style="width: 61px;" id="provincialCapital">
					
						</select>
			      	</div>
   					<input type="text" class="form-control" id="licensePlate2" onkeyup="this.value=this.value.toUpperCase()"
   					>
    			
			</div>
			<br />
			<div class="input-group" id="type">
				<span class="input-group-addon">使用时限(月)：</span>  <input type="text" class="form-control" id="timeLimit" placeholder="示例 001,010,101">
			</div>
		</div>
	</div>
</body>
<script src="${pageContext.request.contextPath}/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-table/js/bootstrap-table.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-table/js/bootstrap-table-zh-CN.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-table/js/bootstrap-table-export.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-table/js/tableExport.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-table/js/bootstrap-table-toolbar.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-table/js/bootstrap-table-filter-control.js"></script>
<script src="${pageContext.request.contextPath}/js/date.js"></script>
<!-- layer -->
<script src="${pageContext.request.contextPath}/plugins/layer/2.4/layer.js"></script>
<script>
	var lock = false;
	var id = "${map['id']}";
	var state = "${map['state']}";
	var index = parent.layer.getFrameIndex(window.name);
	$(function() {
		var html='';
		var mycars=["京","沪","浙","苏","粤","鲁","晋","冀",
            "豫","川","渝","辽","吉","黑","皖","鄂",
            "津","贵","云","桂","琼","青","新","藏",
            "蒙","宁","甘","陕","闽","赣","湘"];
		for(var i=0;i<mycars.length;i++){
			html+="<option value='"+mycars[i]+"'>" + mycars[i] + "</option>";
		}
		$("#provincialCapital").html(html);
		if(state==2){
			$("#type").hide();
		}else{
			$("#type").show();
		}
		
	});
	
	function js_method(){
		console.log($("#provincialCapital").val());
	}

	//添加或修改
	function insertData() {
			var tel=$("#tel").val();
			var provincialCapital=$("#provincialCapital").val();
			var licensePlate2=$("#licensePlate2").val();
			var timeLimit=$("#timeLimit").val();
			var licensePlate=provincialCapital+licensePlate2;
			console.log(timeLimit);
        	lock = true;
    		$.ajax({
    			url : '${pageContext.request.contextPath}/updateParkingSpaceState',
    			type : "post",
    			data : {
    				id : id,
    				state : state,
    				timeLimit:timeLimit,
    				tel:tel,
    				licensePlate:licensePlate
    			},
    			dataType : "json",
    			success : function(data) {
    				var result = data['result'];
    				if (result == 1) {
    					layer.msg('操作成功!', {
    						icon : 1,
    						time : 800
    					});
    					setTimeout(function() {
    						parent.querry();
    						parent.layer.close(index);
    					}, 1000);
    				}else if(result == 2){
    					layer.msg('该车位无出售价格!', {
    						icon : 2,
    						time : 800
    					});
    					lock = false;
    				} else {
    					layer.msg('操作失败!', {
    						icon : 2,
    						time : 800
    					});
    					lock = false;
    				}
    			}
    		}); 
	}
	
	function querry() {
		$("#table").bootstrapTable('refresh');
	}

	function insert() {
		if (!lock) {
			insertData();
		}
	}
</script>
</html>
